//
//  F2DTexture.h
//  Framework2D
//
//  Created by Jorge Lorenzon on 5/29/12.
//  Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//

//martin

#import <OpenGLES/ES1/gl.h>

// Enumerators for the different pixel formats this class can handle
typedef enum {
	kTexture2DPixelFormat_Automatic = 0,
	kTexture2DPixelFormat_RGBA8888,
	kTexture2DPixelFormat_RGB565,
	kTexture2DPixelFormat_A8,
} Texture2DPixelFormat;

// The Texture2D class allows any image to be converted into an OpenGL texture.  As
// input this class takes a UIImage instance for the image to be used as a texture
// and also takes a filter.  This filter is used to set the textures Min and Mag filters
// that are used when you scale an image up and down.
//
// OpenGL textures within OpenGL ES 1.1 are termed power or 2 textures.  That means that their
// width and height need to be a power of 2.  This does not mean that the width and height have
// to be the same e.g. 256x256, but they each have to be a power of 2 e.g. 64x128.
//
// Regardless of the size of the image passed in, this class calculates the necessary power of 2 
// size for the texture and provides the necessary information for you to then acces the texture
// or any part of the texture
//
// As the texture generated by this class could be larger than the actual image it contains, two
// variables called maxS and maxT provide the maximum texture coordinates that define the size of 
// the image within the texture.
//
@interface F2DTexture : NSObject {
    
@private
	
	GLuint name;			// Holds the OpenGL name generated for this texture
	CGSize contentSize;		// Stores the actual size of the image being loaded as a texture
	NSUInteger width;		// The actual width and height of the texture once it has been adjusted to be
	NSUInteger height;		// power of 2 compliant
	GLfloat	maxS;			// Maximum texture coordinates for the image that has been placed inside our texture.
	GLfloat	maxT;
    CGSize textureRatio;	// The ratio between pixels and texels (texture coordinates)
    Texture2DPixelFormat pixelFormat;	// The pixel format of the image that has been loaded
}

@property(nonatomic, readonly) GLuint name;
@property(nonatomic, readonly) CGSize contentSize;
@property(nonatomic, readonly) NSUInteger width;
@property(nonatomic, readonly) NSUInteger height;
@property(nonatomic, readonly) GLfloat maxS;
@property(nonatomic, readonly) GLfloat maxT;
@property(nonatomic, readonly) CGSize textureRatio;
@property(nonatomic, readonly) Texture2DPixelFormat pixelFormat;

// Designated initializer that takes a UIImage and a filter (used for the MIN and MAG settings
// of the texture) and creates an OpenGL texture.
- (id) initWithImage:(UIImage*)aImage filter:(GLenum)aFilter;

- (id) initWithContentsFromFile:(NSString*)filename filter:(GLenum)aFilter;

@end